package cn.changein.framework.admin.setting.customer.controller;

import cn.changein.framework.base.controller.BaseController;
import cn.changein.framework.base.pojo.page.PageInfo;
import cn.changein.framework.kernel.model.response.ResponseData;
import cn.changein.framework.model.setting.customer.entity.CustomerService;
import cn.changein.framework.model.setting.customer.model.params.CustomerServiceParam;
import cn.changein.framework.service.setting.customer.CustomerServiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 客服管理控制器
 *

 * @Date 2021-02-22 16:59:35
 * @Copyright: companyName
 * @Version 1.0
 * @Since JDK1.8
 */
@Controller
@RequestMapping("/customerService")
public class CustomerServiceController extends BaseController {

    private String PREFIX = "/modular/setting/customerService";

    @Autowired
    private CustomerServiceService customerServiceService;

    /**
     * 跳转到主页面
     *

     * @Date 2021-02-22
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/customerService.html";
    }

    /**
     * 新增页面
     *

     * @Date 2021-02-22
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/customerService_add.html";
    }

    /**
     * 编辑页面
     *

     * @Date 2021-02-22
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/customerService_edit.html";
    }

    /**
     * 新增接口
     *

     * @Date 2021-02-22
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(CustomerServiceParam customerServiceParam) {
        this.customerServiceService.add(customerServiceParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *

     * @Date 2021-02-22
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(CustomerServiceParam customerServiceParam) {
        this.customerServiceService.update(customerServiceParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *

     * @Date 2021-02-22
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(CustomerServiceParam customerServiceParam) {
        this.customerServiceService.delete(customerServiceParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *

     * @Date 2021-02-22
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(CustomerServiceParam customerServiceParam) {
        CustomerService detail = this.customerServiceService.getById(customerServiceParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *

     * @Date 2021-02-22
     */
    @ResponseBody
    @RequestMapping("/list")
    public PageInfo list(CustomerServiceParam customerServiceParam) {
        return this.customerServiceService.findPageBySpec(customerServiceParam);
    }

}


